package com.zhang.hadoop.spring.checker;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.ReflectionUtils;

import javax.annotation.Resource;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author zhang yufei
 * @date 2022/6/28 18:30
 **/
@RunWith(SpringRunner.class)
@SpringBootTest
public class CheckerTest {

    @Resource
    private CheckerBusiness checkerBusiness;

    @Test
    public void test01() throws Exception {
        UserBO bo = new UserBO();
        bo.setId(1L);
        bo.setSex(1);
        PhoneBO phoneBO = new PhoneBO();
        phoneBO.setPhoneNumber("12312341234");
        bo.setPhoneBO(phoneBO);
        List<BookBO> bookBOList = new ArrayList<>();
        BookBO bookBO = new BookBO();
        bookBO.setBookName("书名");
        bookBOList.add(bookBO);
        bo.setBookBOList(bookBOList);
        Method method= ReflectionUtils.findMethod(checkerBusiness.getClass(), "add");
        ValidatorUtil.validateMethod(checkerBusiness, method, Arrays.asList(bo, null).toArray());
        checkerBusiness.add(bo, null);
    }
}
